/*
 * @Author: miteng 973203639@qq.com
 * @Date: 2023-12-21 09:19:21
 * @LastEditors: 郝奔 1425466221@qq.com
 * @LastEditTime: 2024-12-10 16:32:56
 * @Description: 
 * Copyright (c) 2024-present HBIS Digital Technology Co.,Ltd. All rights reserved. 
 */
import { default as request, cloud } from '@/framework/utils/request';
import { ResFile, ReqDetail, FileInfo } from './types';
import { ResultData, ResultDataList } from '@/framework/api/common';
//文件管理列表
export function fileInfoListPage(params: ResFile): Promise<ResultDataList<ResFile>> {
  return request({
    url: cloud.file + '/sysFileInfo/fileInfoListPage',
    method: 'get',
    params
  });
}
//查看详情
export function detail(params: ReqDetail): Promise<ResultData<ResFile>> {
  return request({
    url: cloud.file + '/sysFileInfo/detail',
    method: 'get',
    params
  });
}
//删除
export function deleteReally(data: ResFile): Promise<ResultData<null>> {
  return request({
    url: cloud.file + '/sysFileInfo/deleteReally',
    method: 'post',
    data
  });
}

/**
 * 上传文件
 *
 * @param file
 */
export function uploadFileApi(file: File): Promise<ResultData<FileInfo>> {
  // const formData = new FormData();
  // formData.append('file', file);
  // formData.append('secretFlag', 'N')
  // //http://18.10.255.9:9377/stage-api/sysFileInfo/upload
  // // default: process.env.VUE_APP_BASE_API + cloud.file + '/sysFileInfo/upload', // 上传地址，必填
  // // console.log(process.env.VUE_APP_BASE_API + cloud.file + '/sysFileInfo/upload')
  // return request({
  //   // url: '/api/v1/files',
  //   url: cloud.sysBasic + '/sysFileInfo/upload', // 上传地址，必填
  //   method: 'post',
  //   data: formData,
  //   headers: {
  //     'Content-Type': 'multipart/form-data'
  //   }
  // });
  const formData = new FormData();
    formData.append('file', file);
    formData.append('secretFlag', 'N')
    // if (fileParam) {
    //     for (const key in fileParam) {
    //         formData.append(key, fileParam[key])
    //     }
    // }
    return request({
        url: cloud.sysBasic + '/sysFileInfo/upload',
        method: 'post',
        data: formData,
        headers: { 'Content-Type': 'multipart/form-data' }
    });
}
